import { Injectable,HttpException, HttpStatus  } from '@nestjs/common';
import { InjectRepository } from '@nestjs/typeorm';
import { Sign,Score,User } from '../entity';
import { Repository,EntityRepository } from 'typeorm';
import { AppError } from '../error/index';

@Injectable()
export class SignService {
  constructor(

    @InjectRepository(Sign)
    private readonly signRepository: Repository<Sign>,

    @InjectRepository(Score)
    private readonly scoreRepository: Repository<Score>,

    @InjectRepository(User)
    private readonly userRepository: Repository<User>
    ) { }
  
  async findOne(id: number): Promise<{}> {
    const result = await this.signRepository.findOne({ id });
    if (result) {
      return result;
    }
    throw new AppError('未找到相关内容', 20);
  }

  async createSign(body): Promise<{}>{
    const result = await this.signRepository.save(body);
    return result;
  }
}